選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

[...nextauth].ts 773B

123456789101112131415161718192021222324252627282930
  1. import { NextApiRequest, NextApiResponse } from 'next'
  2. import NextAuth from 'next-auth'
  3. import Providers from 'next-auth/providers'
  4. const options = {
  5. providers: [
  6. Providers.GitHub({
  7. clientId: process.env.GITHUB_ID,
  8. clientSecret: process.env.GITHUB_SECRET,
  9. profile(profile) {
  10. return {
  11. id: profile.id,
  12. login: profile.login,
  13. name: profile.name || profile.login,
  14. email: profile.email,
  15. image: profile.avatar_url,
  16. } as any
  17. },
  18. }),
  19. ],
  20. callbacks: {
  21. async redirect(url: string, baseUrl: string) {
  22. return url.startsWith(baseUrl) ? url : baseUrl
  23. },
  24. },
  25. }
  26. export default function (req: NextApiRequest, res: NextApiResponse) {
  27. return NextAuth(req, res, options)
  28. }